//
//  NSSting+Size.m
//  xpkc
//
//  Created by TopSage on 15/11/9.
//  Copyright (c) 2015年 TopSage. All rights reserved.
//

#import "NSSting+Size.h"

@implementation NSString(Size)

- (CGFloat)heightForString:(NSString *)str withWidth:(CGFloat)width andFont:(UIFont *)font{
    UITextView *text = [[UITextView alloc]initWithFrame:CGRectMake(0, 0, width, 1)];
    text.font = font;
    text.text = str;
    [text sizeToFit];
    return text.frame.size.height;
}
- (CGFloat)heightForWidth:(CGFloat)width andFont:(UIFont *)font{
    UITextView *text = [[UITextView alloc]initWithFrame:CGRectMake(0, 0, width, 1)];
    text.font = font;
    text.text = self;
    [text sizeToFit];
    return text.frame.size.height;
}

@end
